<!DOCTYPE HTML>
<html>
<head>
    <title>接口对接日志</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <style>
        .discell{
            text-align:right;
            width:100px;
        }
    </style>
</head>
<body>
<div class="role-search">
    <div class="mini-toolbar" style="padding: 2px;border-top:0;border-left:0;border-right:0;">
        <table>
            <tr style="width: 100%;">
                <td class="discell" style="white-space: nowrap;text-align:right;">省份：</td>
                <td>
                    <input id="province" name="province" class="mini-combobox" textField="codeName" valueField="codeId"
                           emptyText="请选择" style="width: 140px"
                           url="/azbj/seelog/getprovince"/>
                </td>
                <td class="discell">时间范围：</td>
                <td style="white-space: nowrap;text-align:right;">
                    <input id="begintime" name="begintime" class="mini-datepicker" emptyText="开始日期"
                           ondrawdate="onDrawDate"/>
                </td>
                <td style="white-space: nowrap;text-align:right;">
                    <input id="endtime" name="endtime" class="mini-datepicker" emptyText="结束日期"
                           ondrawdate="onDrawDate"/>
                </td>
                <td class="discell">标识：</td>
                <td style="white-space: nowrap;text-align:right;">
                    <input id="flag" name="flag" class="mini-combobox" data="[{id: '1',name: '成功'},{id: '0',name: '失败'}]" textField="name" valueField="id" emptyText="请选择" />
                </td>
                <td class="discell">人员来源：</td>
                <td style="white-space: nowrap;text-align:right;">
                    <input id="origin" name="origin" class="mini-combobox" data="[{id: '4' ,name: '看守所接口对接' },{id: '6',name: '监狱接口对接'},{id: '8',name: '社矫接口对接'},{id: '0',name: '无'}]" textField="name" valueField="id" emptyText="请选择" >
                </td>
                <td class="discell">
                    <a class="mini-button" onclick="searchInfo()">查询</a>
                </td>
                <td class="discell">
                    <a class="mini-button" onclick="reset()">重置</a>
                </td>
            </tr>
        </table>
    </div>
</div>

<!-- 数据填充到下面 -->
<div class="mini-fit">
    <div id="data1" class="mini-datagrid" style="width: 100%; height: 100%;" ajaxType="get" multiSelect="false"
         pageSize="50" virtualScroll="false" showLoading="true"
         idField="id" url="/azbj/seelog/getAllLog">
        <div property="columns">
            <div type="indexcolumn" width="10" headerAlign="center">序号</div>
            <div name="province" field="province" align="center" width="20" headerAlign="center" allowSort="false" renderer="setProvince" >省份</div>
            <div name="account" field="account" align="center" width="25" headerAlign="center" allowSort="false">用户账号</div>
            <div name="date" field="date" align="center" width="23" headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss" >时间</div>
            <div name="flag" field="flag" align="center" width="15" renderer="biaoshi" headerAlign="center">标识</div>
            <div name="origin" field="origin" align="center" width="20" renderer="laiyuan" headerAlign="center">来源</div>
            <div name="action" headerAlign="center" align="center" width="35" renderer="onActionRenderer" cellStyle="padding:0;"
                 allowSort="false" multiSelect="false">操作
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    mini.parse();
    var province = mini.get('province');
    var begintime = mini.get('begintime');
    var endtime = mini.get('endtime');
    var pageSize = 10;
    var flag = mini.get('flag');
    var origin = mini.get('origin');
    //得到数据列表对象
    var grid = mini.get("data1");
    //执行列表对象的url
    grid.load();

    //查询按钮动作
    function searchInfo() {
        //分页查询日志信息
        getInfo();
    }

    //重置按钮动作
    function reset() {
        province.setValue('');
        begintime.setValue('');
        endtime.setValue('');
        flag.setValue('');
        origin.setValue('');
        //重新查询所有数据
        grid.load();
    }

    //设置开始时间
    function onDrawDate(e) {
        var date = e.date;
        var d = new Date();
        if (date.getTime() > d.getTime()) {
            e.allowSelect = false;
        }
    }

    //分页查询日志信息
    function getInfo() {
        var params = {
            province:province.getValue(),
            beginTime: mini.formatDate(begintime.getValue(),'yyyy-MM-dd HH:mm:ss'),
            endTime: mini.formatDate(endtime.getValue(),'yyyy-MM-dd HH:mm:ss'),
            flag: flag.getValue(),
            origin: origin.getValue()
        }
        //表格加载参数
        grid.load(params);
    }

    //标识渲染
    function biaoshi(e) {
        var flag = [{id: 0, text: '失败'},{id: 1, text: '成功'}];
        for (var i = 0; i < flag.length; i++) {
            var g = flag[i];
            if (g.id == e.value){
                return g.text;
            }
        }
    }

    //人员来源渲染
    function laiyuan(e) {
        var origin = [{id: 4 ,text: '看守所接口对接' },{id: 6,text: '监狱接口对接'},{id: 8,text: '社矫接口对接'},{id: null,text: '无'}];
        for (var i = 0; i < origin.length; i++) {
            var g = origin[i];
            if (g.id == e.value) {
                return g.text;
            }
        }
    }

    //操作列控制按钮
    function onActionRenderer() {
        var s = '';
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="checkErrorMessage()" >&nbsp;查看&nbsp;</a>&nbsp';
        return s;
    }

    //查看按钮动作
    function checkErrorMessage() {
        var row = grid.getSelected();
        var id = row.id;
        if (row) {
            commonEdit("/azbj/seelog/seejiekourizhi/seeview/view?id=" + id, "查看", row, 640, 450, true, false, true, callback);
            function callback() {
                grid.reload();
            }
        } else {
            mini.alert('请至少选择一条数据');
        }
    }

</script>
</body>
</html>